/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package backing;

import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import officeboost.domain.VenueService;
import officeboost.domain.equip_venue.Venue;

/**
 *
 * @author XJ
 */
@ManagedBean
public class LocationAdminBacking {
    private String name;
    private String usage;
    private String capacity;
    private String nametodelete;
    @EJB
    private VenueService venueService;
    private List<Venue> venueList;
    private String nametoview;
    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
    
    public String getNametoview() {
        return nametoview;
    }

    public void setNametoview(String nametoview) {
        this.nametoview = nametoview;
    }
    
    public List<Venue> getVenueList() {
        return venueList;
    }

    public void setVenueList(List<Venue> venueList) {
        this.venueList = venueList;
    }
    
    public String getCapacity() {
        return capacity;
    }

    public void setCapacity(String capacity) {
        this.capacity = capacity;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getNametodelete() {
        return nametodelete;
    }

    public void setNametodelete(String nametodelete) {
        this.nametodelete = nametodelete;
    }

    public String getUsage() {
        return usage;
    }

    public void setUsage(String usage) {
        this.usage = usage;
    }
    
    public String addLocation(){
        Venue v=new Venue();
        v.setId(this.name);
        v.setTankage(this.capacity);
        v.setTheUsage(this.usage);
        venueService.persist(v);
        return "location";
    }
    public String deleteLocation(){
        venueService.deleteById(this.nametodelete);
        return "location";
    }
    
    public String viewLocation(){
        if(venueService.resultReservationList(this.nametoview)!=null)
            this.setMessage(venueService.resultReservationList(this.nametoview));
        return "location";
    }
    public void init(){

        this.setVenueList(venueService.findAll());
    }
}
